﻿<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <%@ page session="true" %>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=1600, initial-scale=1.0">
    <link rel="stylesheet" href="icofont/css/all.css">
    <link rel="stylesheet" href="css/common.css">
    <link rel="stylesheet" href="css/user.css">
    <link rel="shortcut icon" href="images/favicon.ico">
    <title>修改密码</title>
</head>

<body>
    <div class="nav">
        <a href="#"><img src="images/logo.png" width="130" height="48"></a>
        <ul>
            <li><a href="/query/manager"><span class="fas font">&#xf21b;</span>管理员入口</a></li>
            <li><a href="/query/user/search"><span class="fas font">&#xf7f2;</span>我的问卷</a></li>
            <li>
                <div class="usr">
                    <span class="fas font">&#xf508;</span>${user.userName}
                    <div class="choice">
                        <span class="fas font"><a href="/query/user">&#xf02d;用户信息</a></span>
                        <p class="line"></p>
                        <span class="fas font"><a href="/query/logout">&#xf14d;退出登录</a></span>
                    </div>
                </div>
            </li>
        </ul>
    </div>
    <div>
        <div class="menu">
            <span><a href="/query/user/addQuery">+创建问卷</a></span>
            <span class="fas font"><a href="/query/user/search">&#xf002;&nbsp;&nbsp;搜索问卷</a></span>
            <span class="fas font"><a href="/query/user/updatePassword">&#xf084;&nbsp;&nbsp;修改密码</a></span>
            <span class="fas font"><a href="/query/user">&#xf2c2;&nbsp;&nbsp;用户信息</a></span>
            <span class="fas font"><a href="/query/logout">&#xf14d;&nbsp;&nbsp;退出登录</a></span>
        </div>
        <div class="content">
            <div class="title">
                <span class="fas font">&#xf084;&nbsp;&nbsp;修改密码</span>
            </div>
            <div class="main-wrap">
                <div class="result-wrap">
                    <form action="#" method="post" id="myform" name="myform">
                        <div class="config-items">
                            <div class="result-content">
                                <table width="100%" class="insert-tab">
                                    <tr>
                                        <th><i class="require-red">*</i>旧密码</th>
                                        <td><input type="password" id="oldPassword" value="" placeholder="旧密码" size="32" name="oldPassword"
                                                class="common-text" maxlength="16"></td>
                                    </tr>
                                    <tr>
                                        <th><i class="require-red">*</i>新密码</th>
                                        <td><input type="password" id="newPassword" value="" placeholder="新密码" size="32" name="newPassword"
                                                class="common-text" maxlength="16"></td>
                                    </tr>
                                    <tr>
                                        <th><i class="require-red">*</i>重复密码</th>
                                        <td><input type="password" id="passwordAgain" value="" placeholder="重复密码" size="32" name="passwordAgain"
                                                class="common-text" maxlength="16"></td>
                                    </tr>
                                    <tr>
                                        <th></th>
                                        <td>
                                            <input type="button" id="update" value="修改" class="btn btn-primary btn6 mr10">
                                            <input type="button" value="返回" class="btn btn6">
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</body>
<script src="js/jquery-3.6.0.min.js"></script>
<script>
    $("#update").click(function(){
        var old = $("#oldPassword").val();
        var newPassword = $("#newPassword").val();
        var again = $("#passwordAgain").val();
        if(!old){
            alert("输入不能为空!");
        }else if(!newPassword){
            alert("输入不能为空!");
        }else if(!again){
            alert("输入不能为空!");
        }else if(newPassword!=again){
            alert("两次输入密码不一致!");
        }else{
            var param = {"oldPassword":old,"newPassword":newPassword};
            $.post("/query/user/updatePassword",param,function(result){
                if(result=="true"){
                    alert("修改成功!");
                }else{
                    alert("旧密码输入错误，修改失败!");
                }
            })
        }
    })
</script>
</html>